import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HomeNav extends StatelessWidget {
  HomeNav({super.key});

  // 导航数据
  List navList = [
    {'title': '我的房屋', 'icon': 'assets/images/house_nav_icon@2x.png', 'path': '/house'},
    {'title': '我的报修', 'icon': 'assets/images/repair_nav_icon@2x.png'},
    {'title': '访客登记', 'icon': 'assets/images/visitor_nav_icon@2x.png'},
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),

      child: Padding(
        padding: EdgeInsets.all(8),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children:
              navList.map((item) {
                return GestureDetector(
                  child: Column(
                    children: [
                      Image.asset(item['icon'], width: 35),
                      Text(item['title']),
                    ],
                  ),
                  onTap: () {
                    if (item['title'] == '我的报修') {
                      Get.toNamed('/repair');
                    } else {
                      Navigator.pushNamed(context, item['path']);
                    }
                  },
                );
              }).toList(),
        ),
      ),
    );
  }
}
